
package com.tencent.weibo.api
{
	import com.tencent.weibo.log.LevelLogger;
	import com.tencent.weibo.operation.IRequestOperation;
	import com.tencent.weibo.operation.URLRequestOperation;
	
	import flash.events.IEventDispatcher;
	
	import mx.logging.ILogger;
	
	/**
	 * 数据收藏相关的API
	 * @langversion 3.0
	 * @playerversion Flash 9
	 * @playerversion AIR 1.1
	 *
	 */
	public class Favorite extends AbstractAPI
	{
		/**
		 * 日志输出对象
		 */
		public static var logger:ILogger=LevelLogger.getLogger("com.tencent.weibo.api.Favorite");
		
		/**
		 * 1.收藏一条微博
		 * @param id 微博id
		 * @return IRequestOperation实例
		 */		
		public function addT(id:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"fav/addt";
			var attachParms:Object = {};
			attachParms.id = id;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 2.删除一条微博从收藏
		 * @param id 微博id
		 * @return IRequestOperation实例
		 */		
		public function delT(id:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"fav/delt";
			var attachParms:Object = {};
			attachParms.id = id;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 3.收藏的微博列表
		 * @param pageflag 分页标识（0：第一页，1：向下翻页，2向上翻页）
		 * @param pagetime 翻页用，第一页时：填0；向上翻页：填上一次请求返回的第一条记录时间；向下翻页：填上一次请求返回的最后一条记录时间
		 * @param reqnum 每次请求记录的条数（1-20条）
		 * @param lastid 第一页时填0,继续向下翻页，填上一次请求返回的最后一条记录id，翻页用
		 * @return IRequestOperation实例
		 */		
		public function listT(pageflag:int=0,pagetime:String="0",reqnum:int=20,lastid:String="0"):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"fav/list_t";
			var attachParms:Object = {};
			attachParms.pageflag = pageflag;
			attachParms.pagetime = pagetime;
			attachParms.reqnum = reqnum;
			attachParms.lastid = lastid;
			return generateDataRequest(url,attachParms,config.requestMethod);
		}
		/**
		 * 4.订阅话题
		 * @param id 需要收藏的话题id
		 * @return IRequestOperation实例
		 */		
		public function addHT(id:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"fav/addht";
			var attachParms:Object = {};
			attachParms.id = id;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 5.取消订阅话题
		 * @param id 话题id
		 * @return IRequestOperation实例
		 */		
		public function delHT(id:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"fav/delht";
			var attachParms:Object = {};
			attachParms.id = id;
			return generateDataRequest(url,attachParms,"POST");
		}
		/**
		 * 6.获取已订阅话题列表
		 * @param reqnum 请求数，最多15
		 * @param pageflag 翻页标识 0：首页 1：向下翻页 2：向上翻页
		 * @param pagetime 翻页用，第一页时：填0；向上翻页：填上一次请求返回的第一条记录时间；向下翻页：填上一次请求返回的最后一条记录时间
		 * @param lastid 翻页话题id，第1次请求时为0
		 * @return IRequestOperation实例
		 */			
		public function listHT(reqnum:int=10,pageflag:int=0,pagetime:String="0",lastid:String="0"):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"fav/list_ht";
			var attachParms:Object = {};
			attachParms.reqnum = reqnum;
			attachParms.pageflag = pageflag;
			attachParms.pagetime = pagetime;
			attachParms.lastid = lastid;
			return generateDataRequest(url,attachParms,config.requestMethod);
		}
	}
}